package com.itic.mall.system.marketuser.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.mall.system.marketuser.persistence.dao.MarketUserDao;
import com.itic.mall.system.marketuser.persistence.model.MarketUser;
import com.itic.mall.system.marketuser.persistence.model.MarketUserExample;
import com.itic.mall.system.profitmoney.persistence.dao.ProfitMoneyDao;
import com.itic.mall.system.profitmoney.persistence.model.ProfitMoney;


@Service
@Transactional
public class MarketUserService
     extends CrudService<MarketUserDao,MarketUser,MarketUserExample> {
    @Autowired
    private MarketUserDao marketUserDao;
    @Autowired
    private ProfitMoneyDao profitMoneyDao;
    
    public List<String> getBindedTgwUserIds(){
    	List<String> userIds = this.marketUserDao.getBindedTgwUserIds();
    	return userIds;
    }
   
	public MarketUser getByInvitingCode(String username) {
		return marketUserDao.getByInvitingCode(username);
	}

	public MarketUser getByUnionid(String unionId) {
		return marketUserDao.getByUnionid(unionId);
	}

	public String bind(MarketUser marketUser, MarketUser user1, MarketUser user2) {
		marketUserDao.updateByPrimaryKeySelective(marketUser);
		marketUserDao.updateByPrimaryKeySelective(user1);
		marketUserDao.updateByPrimaryKeySelective(user2);
		return SUCCESS;
	}


	public String editMoney(MarketUser user, ProfitMoney profitMoney) {
		marketUserDao.updateByPrimaryKeySelective(user);
		profitMoneyDao.insert(profitMoney);
		return SUCCESS;
	}

	public Double getProfit(String id) {
		return marketUserDao.getProfit(id);
	}

	public MarketUser getUserByInvitingCode(String code) {
		return marketUserDao.getUserByInvitingCode(code);
	}
	

}